<template>
    <div v-loading="loading" class="out-put">
        <!-- 标题 -->
        <!-- <div class="new-title">结果输出</div> -->
        <div>
            <el-form
                ref="endForm"
                :model="endForm"
                :rules="rules"
                label-width="140px"
                size="small"
                label-position="left"
            >
                <el-tabs v-model="selected" tab-position="left" class="tabs">
                    <el-tab-pane label="数据项集维护" name="first">
                        <div class="out-form">
                            <el-row :gutter="20">
                                <el-col :span="12">
                                    <el-form-item label="源表中文名称:">
                                        <div>{{ endForm.sourceTableChineseName }}</div>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="12">
                                    <el-form-item label="源表英文名称:">
                                        <div>{{ endForm.sourceTableName }}</div>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row :gutter="20">
                                <el-col :span="12">
                                    <el-form-item label="数据项集中文名称:" prop="tableChineseName">
                                        <el-input v-model="endForm.tableChineseName"
                                                  :disabled="getReadOnlyFlag"></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="12">
                                    <el-form-item label="数据项集英文名称:" prop="tableName">
                                        <el-input
                                            v-model="endForm.tableName"
                                            maxlength="30"
                                            :disabled="getReadOnlyFlag"
                                        ></el-input>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row :gutter="20">
                                <el-col :span="12">
                                    <el-form-item label="数据来源:" prop="dataSourceParent">
                                        <el-row>
                                            <el-col :span="12">
                                                <el-select
                                                    v-model="endForm.dataSourceParent"
                                                    :disabled="getReadOnlyFlag"
                                                    placeholder="请选择"
                                                    class="w100"
                                                    @change="selectEjList"
                                                >
                                                    <el-option
                                                        v-for="(item,index) in dataSourceParentlist"
                                                        :key="index"
                                                        :label="item.dataName"
                                                        :value="item.dataValue"
                                                    ></el-option>
                                                </el-select>
                                            </el-col>
                                            <el-col :span="12">
                                                <el-select
                                                    v-model="endForm.dataSourceChild"
                                                    :disabled="getReadOnlyFlag"
                                                    placeholder="请选择"
                                                    class="w100"
                                                >
                                                    <el-option
                                                        v-for="(item,index) in dataSourceChildlist"
                                                        :key="index"
                                                        :label="item.dataName"
                                                        :value="item.dataValue"
                                                    ></el-option>
                                                </el-select>
                                            </el-col>
                                        </el-row>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="12">
                                    <el-form-item label="业务类型:" prop="businessType">
                                        <el-select
                                            v-model="endForm.businessType"
                                            :disabled="getReadOnlyFlag"
                                            placeholder="请选择"
                                        >
                                            <el-option
                                                v-for="item in getDictionaryList.YWLX"
                                                :key="item.dataValue"
                                                :label="item.dataName"
                                                :value="item.dataValue"
                                            ></el-option>
                                        </el-select>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="12">
                                    <el-form-item label="数据老化时间:" prop="dataOldTime">
                                        <el-input
                                            :disabled="getReadOnlyFlag"
                                            v-model.number="endForm.dataOldTime"
                                            placeholder
                                        >
                                            <template slot="append">天</template>
                                        </el-input>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <div class="expand-bar" @click="toggleExp">{{ expand?'收起详情':'展开详情' }}</div>
                            <div v-if="expand" class="out-form">
                                <el-row :gutter="20">
                                    <el-col :span="12">
                                        <el-form-item label="来源分类:" prop="sourceType">
                                            <el-select
                                                :disabled="getReadOnlyFlag"
                                                v-model="endForm.sourceType"
                                                placeholder="请选择"
                                            >
                                                <el-option
                                                    v-for="item in getDictionaryList.SJLYXTFLBM"
                                                    :key="item.dataValue"
                                                    :label="item.dataName"
                                                    :value="item.dataValue"
                                                ></el-option>
                                            </el-select>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="敏感等级:" prop="sensitiveGrade">
                                            <el-select
                                                :disabled="getReadOnlyFlag"
                                                v-model="endForm.sensitiveGrade"
                                                placeholder="请选择"
                                            >
                                                <el-option
                                                    v-for="item in getDictionaryList.SJJLMGJB"
                                                    :key="item.dataValue"
                                                    :label="item.dataName"
                                                    :value="item.dataValue"
                                                ></el-option>
                                            </el-select>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row :gutter="20">
                                    <el-col :span="12">
                                        <el-form-item label="数据范围:" prop="dataRange">
                                            <el-select
                                                v-model="endForm.dataRange"
                                                placeholder="请选择"
                                                :disabled="getReadOnlyFlag"
                                            >
                                                <el-option
                                                    v-for="item in getDictionaryList.BusinessLevel"
                                                    :key="item.dataValue"
                                                    :label="item.dataName"
                                                    :value="item.dataValue"
                                                ></el-option>
                                            </el-select>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="数据说明:" prop="dataComments">
                                            <el-input :disabled="getReadOnlyFlag"
                                                      v-model="endForm.dataComments"></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row :gutter="20">
                                    <el-col :span="12">
                                        <el-form-item label="采集地:" prop="collectPlaces">
                                            <el-row>
                                                <el-col :span="8">
                                                    <el-select
                                                        :disabled="getReadOnlyFlag"
                                                        v-model="endForm.provinceValue"
                                                        placeholder="请选择"
                                                        @change="selectProvimce"
                                                    >
                                                        <el-option
                                                            v-for="(item,index) of provincearr"
                                                            :key="index"
                                                            :label="item.dataName"
                                                            :value="item.dataValue"
                                                        ></el-option>
                                                    </el-select>
                                                </el-col>
                                                <el-col :span="8">
                                                    <el-select
                                                        :disabled="getReadOnlyFlag"
                                                        v-model="endForm.cityValue"
                                                        placeholder="请选择"
                                                        @change="selectcity"
                                                    >
                                                        <el-option
                                                            v-for="(item,index) of cityarr"
                                                            :key="index"
                                                            :label="item.dataName"
                                                            :value="item.dataValue"
                                                        ></el-option>
                                                    </el-select>
                                                </el-col>
                                                <el-col :span="8">
                                                    <el-select
                                                        :disabled="getReadOnlyFlag"
                                                        v-model="endForm.regionValue"
                                                        placeholder="请选择"
                                                    >
                                                        <el-option
                                                            v-for="(item,index) of regionarr"
                                                            :key="index"
                                                            :label="item.dataName"
                                                            :value="item.dataValue"
                                                        ></el-option>
                                                    </el-select>
                                                </el-col>
                                            </el-row>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="业务标签:" prop="businessLabel">
                                            <el-input :disabled="getReadOnlyFlag"
                                                      v-model="endForm.businessLabel"></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row :gutter="20">
                                    <el-col :span="12">
                                        <el-form-item label="使用级别:" prop="useLevel">
                                            <el-radio-group :disabled="getReadOnlyFlag" v-model="endForm.useLevel">
                                                <el-radio label="低">低</el-radio>
                                                <el-radio label="中">中</el-radio>
                                                <el-radio label="高">高</el-radio>
                                            </el-radio-group>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                            </div>
                        </div>
                    </el-tab-pane>
                    <el-tab-pane label="接入设置" name="second">
                        <div class="out-form">
                            <el-row>
                                <el-col :span="12">
                                    <el-form-item label="存储库:" prop="storeType">
                                        <el-select
                                            v-model="endForm.storeType"
                                            :disabled="getReadOnlyFlag"
                                            placeholder="请选择"
                                        >
                                            <el-option
                                                v-for="item in storeTypeList"
                                                :key="item"
                                                :label="item"
                                                :value="item"
                                            ></el-option>
                                        </el-select>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row v-if="endForm.storeType ==='Impala'">
                                <el-col :span="12">
                                    <el-form-item label="分区字段:">
                                        <el-select
                                            v-model="endForm.partitionColumn"
                                            :disabled="getReadOnlyFlag"
                                            :clearable="true"
                                            placeholder="请选择"
                                        >
                                            <el-option
                                                v-for="item in partitionColumnList"
                                                :key="item.logicColumnName"
                                                :label="item.logicColumnName"
                                                :value="item.logicColumnName"
                                            ></el-option>
                                        </el-select>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row>
                                <el-col :span="12">
                                    <el-form-item label="接入方式:" prop="accessWay">
                                        <el-radio-group v-model="endForm.accessWay" :disabled="getReadOnlyFlag">
                                            <el-radio v-if="!restfulFlag" label="1">周期增量</el-radio>
                                            <el-radio v-if="!restfulFlag" label="2">周期全量</el-radio>
                                            <el-radio v-if="!restfulFlag" label="3">一次性</el-radio>
                                            <el-radio v-if="restfulFlag" label="4">实时</el-radio>
                                        </el-radio-group>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row v-if="endForm.accessWay=='1'&&!ftpFlag">
                                <el-col :span="12">
                                    <el-form-item label="接入起始点:">
                                        <el-input v-model="endForm.accessStartPoint"
                                                  :disabled="getReadOnlyFlag"></el-input>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row v-if="endForm.accessWay=='1'&&!ftpFlag">
                                <el-col :span="12">
                                    <el-form-item label="增量字段:" prop="incrementalField">
                                        <div class="my-flex">
                                            <el-input v-model="endForm.incrementalField" disabled
                                                      placeholder></el-input>
                                            <i
                                                v-if="!getReadOnlyFlag"
                                                class="iconfont btn-style icon-wenbentianjia font_family ml20"
                                                @click="innerVisible = true"
                                            ></i>
                                        </div>
                                        <incre-map
                                            ref="incremap"
                                            :msg="innerVisible"
                                            :yid="yid"
                                            :alincre="increArr"
                                            :table-data="tableData"
                                            @showIncre="showIncrement()"
                                            @saveIncre="saveIncrement($event)"
                                        ></incre-map>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <div v-if="endForm.accessWay=='1'||endForm.accessWay=='2'">
                                <el-form-item label="周期设置:" prop="cycleSet">
                                    <el-col :span="24" class="line40" style="margin-bottom:15px;">
                                        <el-col :span="1" class="oparadio">
                                            <el-radio v-model="endForm.cycleSet" label="1">&nbsp;</el-radio>
                                        </el-col>
                                        <!-- 迭代四开始 -->
                                        <el-col :span="21">
                                            <el-col :span="3">
                                                <el-form-item class="clearfix">
                                                    <span class="mr10">选择类型</span>
                                                </el-form-item>
                                            </el-col>
                                            <el-col :span="5">
                                                <el-form-item prop="timeType">
                                                    <el-select
                                                        v-model="endForm.timeType"
                                                        placeholder="请选择"
                                                        :disabled="endForm.cycleSet !== '1'"
                                                        @change="endForm.timeValue=''"
                                                    >
                                                        <el-option
                                                            v-for="(value, key) in timeType"
                                                            :key="key"
                                                            :label="key"
                                                            :value="key"
                                                        ></el-option>
                                                    </el-select>
                                                </el-form-item>
                                            </el-col>
                                            <el-col v-if="endForm.timeType" :span="3">
                                                <el-form-item class="clearfix" style="text-align:center">
                                                    <span class="mr10">选择数值</span>
                                                </el-form-item>
                                            </el-col>
                                            <el-col v-if="endForm.timeType" :span="5">
                                                <el-form-item>
                                                    <el-select
                                                        v-model="endForm.timeValue"
                                                        prop="timeValue"
                                                        placeholder="请选择"
                                                        :disabled=" endForm.cycleSet !== '1'"
                                                    >
                                                        <el-option
                                                            v-for="value in getTimeValue"
                                                            :key="value"
                                                            :label="value"
                                                            :value="value"
                                                        ></el-option>
                                                    </el-select>
                                                </el-form-item>
                                            </el-col>
                                        </el-col>
                                    </el-col>
                                    <el-col :span="24" class="line40" style="margin-bottom:15px;">
                                        <el-col :span="1" class="oparadio">
                                            <el-radio v-model="endForm.cycleSet" label="4">&nbsp;</el-radio>
                                        </el-col>
                                        <el-col :span="21">
                                            <el-col :span="3">
                                                <el-form-item class="clearfix">
                                                    <span class="mr10">每天</span>
                                                </el-form-item>
                                            </el-col>
                                            <el-col :span="5">
                                                <el-form-item>
                                                    <el-select
                                                        v-model="endForm.dthour"
                                                        placeholder="请选择"
                                                        :disabled=" endForm.cycleSet !== '4'"
                                                    >
                                                        <el-option
                                                            v-for="item in hourData"
                                                            :key="item"
                                                            :label="item"
                                                            :value="item"
                                                        ></el-option>
                                                    </el-select>
                                                </el-form-item>
                                            </el-col>
                                            <el-col :span="2">
                                                <el-form-item class="clearfix tcenter">
                                                    <div style="margin-left:10px">时</div>
                                                </el-form-item>
                                            </el-col>
                                            <el-col :span="5">
                                                <el-form-item>
                                                    <el-select
                                                        v-if="endForm.dthour || endForm.dthour === 0"
                                                        v-model="endForm.dtmin"
                                                        placeholder="请选择"
                                                        :disabled=" endForm.cycleSet !== '4'"
                                                    >
                                                        <el-option
                                                            v-for="item in minData"
                                                            :key="item"
                                                            :label="item"
                                                            :value="item"
                                                        ></el-option>
                                                    </el-select>
                                                </el-form-item>
                                            </el-col>
                                            <el-col v-if="endForm.dthour || endForm.dthour === 0" :span="2">
                                                <el-form-item class="clearfix tcenter">
                                                    <div style="margin-left:10px">分</div>
                                                </el-form-item>
                                            </el-col>
                                        </el-col>
                                    </el-col>
                                    <el-col :span="24" class="line40" style="margin-bottom:15px;">
                                        <el-col :span="1" class="oparadio">
                                            <el-radio v-model="endForm.cycleSet" label="3">&nbsp;</el-radio>
                                        </el-col>
                                        <el-col :span="21">
                                            <el-col :span="3">
                                                <el-form-item class="clearfix">
                                                    <span class="mr10">每周</span>
                                                </el-form-item>
                                            </el-col>
                                            <el-col :span="5">
                                                <el-form-item>
                                                    <el-select
                                                        v-model="endForm.dsweek"
                                                        placeholder="请选择"
                                                        :disabled=" endForm.cycleSet !== '3'"
                                                    >
                                                        <el-option
                                                            v-for="(item, index) in weekData"
                                                            :key="index"
                                                            :label="'星期'+item.name"
                                                            :value="item.val"
                                                        ></el-option>
                                                    </el-select>
                                                </el-form-item>
                                            </el-col>
                                            <el-col :span="2">
                                                <el-form-item class="clearfix tcenter">
                                                    <span class="mr10"></span>
                                                </el-form-item>
                                            </el-col>
                                            <el-col v-if="endForm.dsweek" :span="4" style="margin-left:20px;">
                                                <el-form-item>
                                                    <el-select
                                                        v-model="endForm.dshour"
                                                        placeholder="请选择"
                                                        :disabled=" endForm.cycleSet !== '3'"
                                                    >
                                                        <el-option
                                                            v-for="item in hourData"
                                                            :key="item"
                                                            :label="item"
                                                            :value="item"
                                                        ></el-option>
                                                    </el-select>
                                                </el-form-item>
                                            </el-col>
                                            <el-col v-if="endForm.dsweek" :span="2">
                                                <el-form-item class="clearfix tcenter">
                                                    <div style="margin-left:10px">时</div>
                                                </el-form-item>
                                            </el-col>
                                            <el-col v-if="endForm.dshour || endForm.dshour===0" :span="4">
                                                <el-form-item>
                                                    <el-select
                                                        v-model="endForm.dsmin"
                                                        placeholder="请选择"
                                                        :disabled=" endForm.cycleSet !== '3'"
                                                    >
                                                        <el-option
                                                            v-for="item in minData"
                                                            :key="item"
                                                            :label="item"
                                                            :value="item"
                                                        ></el-option>
                                                    </el-select>
                                                </el-form-item>
                                            </el-col>
                                            <el-col v-if="endForm.dshour || endForm.dshour===0" :span="2">
                                                <el-form-item class="clearfix tcenter">
                                                    <div style="margin-left:10px">分</div>
                                                </el-form-item>
                                            </el-col>
                                        </el-col>
                                    </el-col>
                                    <el-col :span="24" class="line40" style="margin-bottom:15px;">
                                        <el-col :span="1" class="oparadio">
                                            <el-radio v-model="endForm.cycleSet" label="2">&nbsp;</el-radio>
                                        </el-col>
                                        <el-col :span="21">
                                            <el-col :span="3">
                                                <el-form-item class="clearfix">
                                                    <span class="mr10">每月</span>
                                                </el-form-item>
                                            </el-col>
                                            <el-col :span="5">
                                                <el-form-item>
                                                    <el-select
                                                        v-model="endForm.dfmon"
                                                        placeholder="请选择"
                                                        :disabled=" endForm.cycleSet !== '2'"
                                                    >
                                                        <el-option
                                                            v-for="item in monthData"
                                                            :key="item"
                                                            :label="item"
                                                            :value="item"
                                                        ></el-option>
                                                    </el-select>
                                                </el-form-item>
                                            </el-col>
                                            <el-col :span="2">
                                                <el-form-item class="clearfix tcenter">
                                                    <div style="margin-left:10px">号</div>
                                                </el-form-item>
                                            </el-col>
                                            <el-col v-if="endForm.dfmon" :span="5">
                                                <el-form-item>
                                                    <el-select
                                                        v-model="endForm.dfhour"
                                                        placeholder="请选择"
                                                        :disabled=" endForm.cycleSet !== '2'"
                                                    >
                                                        <el-option
                                                            v-for="item in hourData"
                                                            :key="item"
                                                            :label="item"
                                                            :value="item"
                                                        ></el-option>
                                                    </el-select>
                                                </el-form-item>
                                            </el-col>
                                            <el-col v-if="endForm.dfmon" :span="2">
                                                <el-form-item class="clearfix tcenter">
                                                    <div style="margin-left:10px">时</div>
                                                </el-form-item>
                                            </el-col>
                                            <el-col v-if="endForm.dfhour || endForm.dfhour ===0" :span="5">
                                                <el-form-item>
                                                    <el-select
                                                        v-model="endForm.dfmin"
                                                        placeholder="请选择"
                                                        :disabled=" endForm.cycleSet !== '2'"
                                                    >
                                                        <el-option
                                                            v-for="item in minData"
                                                            :key="item"
                                                            :label="item"
                                                            :value="item"
                                                        ></el-option>
                                                    </el-select>
                                                </el-form-item>
                                            </el-col>
                                            <el-col v-if="endForm.dfhour || endForm.dfhour ===0" :span="2">
                                                <el-form-item class="clearfix tcenter">
                                                    <div style="margin-left:10px">分</div>
                                                </el-form-item>
                                            </el-col>
                                        </el-col>
                                    </el-col>
                                </el-form-item>
                            </div>
                        </div>
                        <div class="btn-bt">
                            <el-button type="primary" @click="newSubmit">提交任务</el-button>
                        </div>
                    </el-tab-pane>
                </el-tabs>
            </el-form>
        </div>
    </div>
</template>

<script>
    import {mapGetters, mapMutations} from "vuex";
    import TIME, {translateTimeFromCRON} from "@/utils/CORN";
    import IncreMap from "./components/incre_map";

    export default {
        components: {
            IncreMap
        },
        data() {
            const blurText = async (rule, value, callback) => {

                if (!value) {
                    return;
                }
                const boolean = new RegExp("^[1-9][0-9]*$").test(value); // console.log(boolean)
                if (!boolean && value !== "") {
                    callback(new Error("请输入数字"));
                }
            };
            const validName = async (rule, value, callback) => {
                callback(new Error("该表名已存在"));
            };

            return {
                validName,
                expand: false,
                loading: false,
                restfulFlag: false,
                ftpFlag: false,
                submitFlag: true,
                yid: "",
                timeType: TIME,
                selected: "first",
                dataSourceParentlist: [],
                dataSourceChildlist: [],
                provincearr: [],
                cityarr: [],
                regionarr: [],
                storeTypeList: [],
                partitionColumnList: [],
                weekData: [],
                monthData: [],
                hourData: [],
                minData: [],
                innerVisible: false,
                increArr: {},
                endOutPut: {},
                tableData: [],
                endForm: {
                    sourceTableChineseName: "",
                    sourceTableName: "",
                    tableChineseName: "",
                    tableName: "",
                    dataSourceParent: "",
                    businessType: "",
                    sourceType: "",
                    sensitiveGrade: "50",
                    dataRange: "",
                    businessLabel: "",
                    useLevel: "低",
                    dataOldTime: "",
                    collectPlaces: "",
                    dataComments: "",
                    dataSourceChild: "",
                    provinceValue: "",
                    cityValue: "",
                    regionValue: "",
                    storeType: "",
                    partitionColumn: "",
                    accessWay: "1",
                    accessStartPoint: "",
                    incrementalField: "",
                    cycleSet: "1", // 周期设置
                    timeType: "",
                    timeValue: "",
                    dthour: "",
                    dtmin: "",
                    dsweek: "",
                    dshour: "",
                    dsmin: "",
                    dfmon: "",
                    dfhour: "",
                    dfmin: "",
                    intervalMs: ""
                },
                secondFlag: false,
                outPutObj: {},
                setFlag: false,
                persentViewFoot: {},
                rules: {
                    dataSourceParent: [
                        {
                            required: true,
                            message: "请选择数据来源",
                            trigger: "change"
                        }
                    ],
                    businessType: [
                        {
                            required: true,
                            message: "请选择业务分类",
                            trigger: "change"
                        }
                    ],
                    tableChineseName: [
                        {
                            required: true,
                            message: "请输入数据项集中文名称",
                            trigger: "blur"
                        },
                        {
                            max: 50,
                            message: "不超过50个字符",
                            trigger: "blur"
                        }
                    ],
                    businessLabel: [
                        {
                            max: 50,
                            message: "不超过50个字符",
                            trigger: "blur"
                        }
                    ],
                    dataComments: [
                        {
                            max: 50,
                            message: "不超过50个字符",
                            trigger: "blur"
                        }
                    ],
                    tableName: [
                        {
                            required: true,
                            message: "请输入数据项集英文名称",
                            trigger: "blur"
                        },
                        {
                            max: 30,
                            message: "不超过30个字符",
                            trigger: "blur"
                        },
                        {
                            pattern: /^[a-zA-Z]+[_a-zA-Z0-9]*$/g,
                            message: "英文字母、数字、下划线组合",
                            trigger: "blur"
                        }
                    ],
                    storeType: [
                        {
                            required: true,
                            message: "请选择存储类型",
                            trigger: "change"
                        }
                    ],
                    accessWay: [
                        {
                            required: true,
                            message: "请选择接入方式",
                            trigger: "change"
                        }
                    ],
                    dataOldTime: [
                        {required: false, message: "输入值", trigger: "blur"},
                        {validator: blurText, trigger: "blur"}
                    ],
                    incrementalField: [
                        {
                            required: true,
                            message: "请选择增量字段",
                            trigger: "change"
                        }
                    ]
                }
            };
        },
        computed: {
            ...mapGetters([
                "getViewFoot",
                "getOperatorInfo",
                "getSubmitInfo",
                "setSubmitInfo",
                "getSourceInfo",
                "getSubmitInfo",
                "getWrapInfo",
                "getReadOnlyFlag",
                "getDelFlag"
            ]),
            flowList() {
                return this.$store.state.flow.flowList;
            },
            getTimeValue() {
                return this.timeType[this.endForm.timeType];
            },
            getDictionaryList() {
                this.getSJZYLYLX(
                    this.$store.state.tree.dictionaryList.SJZYLYLX,
                    "01",
                    ""
                );
                this.getXZQHFBM(this.$store.state.tree.dictionaryList.XZQHFBM, "01");
                return this.$store.state.tree.dictionaryList;
            }
        },
        watch: {
            "endForm.cycleSet": function (newVal, oldVal) {
                switch (newVal) {
                    case "1":
                        this.endForm.dfmon = "";
                        this.endForm.dfhour = "";
                        this.endForm.dfmin = "";
                        this.endForm.dsweek = "";
                        this.endForm.dshour = "";
                        this.endForm.dsmin = "";
                        this.endForm.dthour = "";
                        this.endForm.dtmin = "";
                        break;
                    case "2":
                        this.endForm.timeType = "";
                        this.endForm.timeValue = "";
                        this.endForm.dsweek = "";
                        this.endForm.dshour = "";
                        this.endForm.dsmin = "";
                        this.endForm.dthour = "";
                        this.endForm.dtmin = "";
                        break;
                    case "3":
                        this.endForm.timeType = "";
                        this.endForm.timeValue = "";
                        this.endForm.dfmon = "";
                        this.endForm.dfhour = "";
                        this.endForm.dfmin = "";
                        this.endForm.dthour = "";
                        this.endForm.dtmin = "";
                        break;
                    case "4":
                        this.endForm.timeType = "";
                        this.endForm.timeValue = "";
                        this.endForm.dfmon = "";
                        this.endForm.dfhour = "";
                        this.endForm.dfmin = "";
                        this.endForm.dsweek = "";
                        this.endForm.dshour = "";
                        this.endForm.dsmin = "";
                        break;
                }
            }
        },
        mounted() {
            this.$store.commit("setDelFlag", false);
            this.persentViewFoot = JSON.parse(JSON.stringify(this.getViewFoot));
            this.restfulFlag = !!(
                this.getWrapInfo.assetSourceDialectType == "RESTful(推)" ||
                this.getWrapInfo.assetSourceDialectType == "RESTful(拉)"
            );
            this.ftpFlag = this.getWrapInfo.assetSourceDialectType == "FTP";
            if (this.restfulFlag) {
                this.endForm.accessWay = "4";
                if (this.getWrapInfo.taskStatus != 3 && this.getReadOnlyFlag) {
                    this.submitFlag = false;
                } else {
                    this.submitFlag = true;
                }
            } else {
                this.submitFlag = true;
            }

            this.initOpera();
            this.getStoreData();
            this._monthData();
            this._minData();
            this._hourData();
            this._weekData();
        },
        destroyed() {
            // 如果是删除节点禁止触发销毁钩子
            if (this.getDelFlag) {
                this.$store.commit("setDelFlag", false);
            } else if (!this.setFlag) {
                this.setNodeInfo();
                this.setFlag = true;
            }
        },
        methods: {
            ...mapMutations("flow", ["setResetFlow"]),
            initOpera() {
                if (
                    this.getOperatorInfo[this.getViewFoot.id] &&
                    this.getOperatorInfo[this.getViewFoot.id].flag
                ) {
                    let submitInfo = JSON.parse(
                        JSON.stringify(this.getOperatorInfo[this.getViewFoot.id])
                    );
                    this.endForm = submitInfo.ruleForm;
                    this.outPutObj = submitInfo.outPut;
                    this.secondFlag = true;
                    this.dealForm();
                } else {
                    this.endForm.flag = true;
                    this.endForm.name = this.getViewFoot.name;
                    let submitInfo = this.getSubmitInfo[this.getViewFoot.preNode];
                    this.outPutObj = submitInfo.outPut;
                    if (this.$store.state.tree.readOnlyFlag) {
                        this.endForm = Object.assign(this.endForm, this.getWrapInfo);
                        this.secondFlag = true;
                        this.dealForm();
                    } else {
                        this.endForm.dataSourceParent = this.getSourceInfo.dataSourceParent;
                        this.endForm.dataSourceChild = this.getSourceInfo.dataSourceChild;
                        this.secondFlag = true;
                        this.getSJZYLYLX(
                            this.getDictionaryList.SJZYLYLX,
                            "02",
                            this.endForm.dataSourceParent
                        );
                    }
                }
                let res = this.getSourceInfo;
                this.tableData = res.columnInfo;
                this.endForm.sourceTableChineseName = res.tableChineseName;
                this.endForm.sourceTableName = res.tableName;
                this.partitionColumnList = this.outPutObj.filter(
                    item => item.logicColumnType.toUpperCase() != "TIMESTAMP"
                );
            },
            toggleExp() {
                this.expand = !this.expand;
            },
            async getStoreData() {
                const param = {
                    dbRegionType: "原始库"
                };
                const res = await this.$api.dataMap.getStoreType(param);
                if (res.data.resultCode === 0) {
                    this.storeTypeList = res.data.data;
                }
            },
            setNodeInfo() {
                const ids = this.persentViewFoot.id; // id
                this.dealCollectPlaces();
                const value = {
                    outPut: this.outPutObj,
                    ruleForm: this.endForm,
                    flag: true
                };
                const obj = {};
                obj[ids] = value;
                this.$store.commit("setOperatorInfo", obj); // 将对象存入store，kye-value形式
                // 存放本算子信息，最终提交用
                const submitIds = this.persentViewFoot.id; // id
                // 根据节点id匹配节点坐标
                const arr = this.flowList.nodeList.filter(
                    item => this.persentViewFoot.id === item.id
                );
                const submitValue = {
                    operateName: this.endForm.name,
                    operateType: "0",
                    location: `${arr[0].top},${arr[0].left}`,
                    orderNumber: this.persentViewFoot.id,
                    outPut: this.outPutObj
                };
                const submitObj = {};
                submitObj[submitIds] = submitValue;
                this.$store.commit("setSubmitInfo", submitObj);
            },
            dealForm() {
                let str = this.endForm.collectPlaces ? this.endForm.collectPlaces : [];
                this.endForm.collectPlaces = JSON.parse(str);
                this.endForm.provinceValue = this.endForm.collectPlaces[0]
                    ? this.endForm.collectPlaces[0].proCode
                    : "";
                this.selectProvimce(this.endForm.provinceValue);
                this.endForm.cityValue = this.endForm.collectPlaces[1]
                    ? this.endForm.collectPlaces[1].cityCode
                    : "";
                this.selectcity(this.endForm.cityValue);
                this.endForm.regionValue = this.endForm.collectPlaces[2]
                    ? this.endForm.collectPlaces[2].urbanCode
                    : "";
                this.getSJZYLYLX(
                    this.getDictionaryList.SJZYLYLX,
                    "02",
                    this.endForm.dataSourceParent
                );
                this.translateCron();
            },
            async newSubmit() {
                if (!this.submitFlag) {
                    this.$message({
                        message: "任务为接口的方式，需暂停后才能修改",
                        type: "error"
                    });
                    return false;
                }
                if (this.$store.state.tree.readOnlyFlag) {
                    this.outPut();
                } else {
                    const param1 = {
                        dbRegionType: "原始库",
                        storeType: this.endForm.storeType,
                        tableName: this.endForm.tableName,
                        tableChineseName: this.endForm.tableChineseName
                    };
                    const res1 = await this.$api.home.validOut(param1);
                    if (res1.data.resultCode === 0) {
                        this.outPut();
                    } else {
                        this.selected = "first";
                        if (res1.data.resultCode !== 0) {
                            this.$message({message: res1.data.resultMessage, type: "error"});
                            return false;
                        }
                    }
                }
            },
            dealCollectPlaces() {
                const vm = this;
                const collectPlaces = [];
                const prov = vm.provincearr.find(
                    item => item.dataValue === vm.endForm.provinceValue
                );
                const city = vm.cityarr.find(
                    item => item.dataValue === vm.endForm.cityValue
                );
                const region = vm.regionarr.find(
                    item => item.dataValue === vm.endForm.regionValue
                );
                if (prov) {
                    collectPlaces.push({
                        proCode: prov.dataValue || "",
                        proName: prov.dataName || ""
                    });
                }
                if (city) {
                    collectPlaces.push({
                        cityCode: city.dataValue || "",
                        cityName: city.dataName || ""
                    });
                }
                if (region) {
                    collectPlaces.push({
                        urbanCode: region.dataValue || "",
                        urbanName: region.dataName || ""
                    });
                }
                vm.endForm.collectPlaces = JSON.stringify(collectPlaces);
            },
            async outPut() {
                const vm = this;
                vm.dealCollectPlaces();
                if (!vm.dealIntervalMs()) {
                    return false;
                }
                // vm.dealIntervalMs()
                vm.$refs.endForm.validate(async valid => {
                    if (valid) {
                        vm.loading = true;
                        if (!vm.setFlag) {
                            vm.setNodeInfo();
                            vm.setFlag = true;
                        }
                        vm.endOutPut = Object.assign(vm.endOutPut, vm.endForm);
                        const accessCollectTaskOperate = [];
                        const res = vm.getSubmitInfo;
                        if (res) {
                            for (const key in res) {
                                accessCollectTaskOperate.push(res[key]);
                            }
                            vm.$set(
                                vm.endOutPut,
                                "accessCollectTaskOperate",
                                accessCollectTaskOperate
                            );
                        }

                        vm.$set(vm.endOutPut, "frontParameter", JSON.stringify(vm.flowList));
                        delete vm.endOutPut.tableData; // 移除多余的tableData
                        let log = {};
                        const flag = this.getReadOnlyFlag; // true:已采集，false:未采集
                        if (flag) {
                            log = await vm.$api.home.updateInfo(vm.endOutPut);
                        } else {
                            const wrap = vm.getWrapInfo;
                            vm.endOutPut = Object.assign(vm.endOutPut, wrap);
                            log = await vm.$api.home.submitInfo(vm.endOutPut);
                            vm.loading = false;
                        }
                        if (log.data.resultCode === 0) {
                            vm.$message.success(log.data.resultMessage);
                            this.$store.commit("outPutReset");
                            this.setResetFlow();
                            window.location.reload();
                        } else {
                            vm.$message.error(log.data.resultMessage);
                        }
                    } else {
                        return false;
                    }
                });
            },
            // 选择数据资源来源类型
            selectEjList(val) {
                this.secondFlag = false;
                this.getSJZYLYLX(this.getDictionaryList.SJZYLYLX, "02", val);
            },
            // 数据资源来源类型
            getSJZYLYLX(data, level, pcode) {
                if (!this.secondFlag) {
                    this.endForm.dataSourceChild = "";
                }
                if (level == "01") {
                    this.dataSourceParentlist = [];
                } else if (level == "02") {
                    this.dataSourceChildlist = [];
                }
                data.forEach(element => {
                    if (element.level == "01" && element.pcode == pcode && level == "01") {
                        this.dataSourceParentlist.push(element);
                    }
                    if (element.level == "02" && element.pcode == pcode && level == "02") {
                        this.dataSourceChildlist.push(element);
                    }
                });
            },
            // 采集地
            getXZQHFBM(data, level) {
                const cjdone = [];
                data.forEach(element => {
                    if (element.level === level) {
                        cjdone.push(element);
                    }
                });
                this.provincearr = cjdone;
            },
            selectProvimce(id) {
                const cjdtwo = [];
                this.getDictionaryList.XZQHFBM.forEach(element => {
                    if (element.pcode == id) {
                        cjdtwo.push(element);
                    }
                });
                this.cityarr = cjdtwo;
            },
            selectcity(id) {
                const cjdthree = [];
                this.getDictionaryList.XZQHFBM.forEach(element => {
                    if (element.pcode == id) {
                        cjdthree.push(element);
                    }
                });
                this.regionarr = cjdthree;
            },
            // 增量字段弹框的再次打开
            showIncrement() {
                this.innerVisible = false;
            },
            saveIncrement(value) {
                if (value.name) {
                    this.increArr = value;
                    this.endForm.incrementalField = this.increArr.name;
                    this.innerVisible = false;
                }
            },
            // 关闭对话框
            closeDialog() {
                this.endForm.cycleSet = "1";
                this.endForm.dfmon = "";
                this.endForm.dfhour = "";
                this.endForm.dfmin = "";
                this.endForm.dsweek = "";
                this.endForm.dshour = "";
                this.endForm.dsmin = "";
                this.endForm.dthour = "";
                this.endForm.dtmin = "";
                this.endForm.incrementalField = "";
                this.endForm.timeType = "";
                this.endForm.timeValue = "";
                this.increArr = {};
            },
            dealIntervalMs() {
                let pollIntervalMs = -1;
                if (this.endForm.accessWay == "1" || this.endForm.accessWay == "2") {
                    if (this.endForm.cycleSet == "1") {
                        if (!this.endForm.timeType || !this.endForm.timeValue) {
                            this.$message.warning("请输入正确的间隔时间");
                            return false;
                        }
                        pollIntervalMs = this.formateCron();
                    } else {
                        if (this.endForm.cycleSet == "") {
                            this.$message.warning("请选择定时执行时间");
                            return false;
                        }
                        if (this.endForm.cycleSet == "2") {
                            // 第一队列
                            let dfmin;
                            let dfhour;
                            let dfmon;
                            if (
                                this.endForm.dfmin === "" ||
                                this.endForm.dfhour === "" ||
                                this.endForm.dfmon == "" ||
                                this.endForm.dfmon == undefined
                            ) {
                                this.$message.warning("请将定时执行时间填写完整");
                                return false;
                            }
                            if (this.endForm.dfmin || this.endForm.dfmin == 0) {
                                dfmin = this.endForm.dfmin;
                            }
                            if (this.endForm.dfhour || this.endForm.dfhour == 0) {
                                dfhour = this.endForm.dfhour;
                            }
                            if (this.endForm.dfmon) {
                                dfmon = this.endForm.dfmon;
                            }
                            pollIntervalMs = `0 ${dfmin} ${dfhour} ${dfmon} * ?`;
                        }
                        if (this.endForm.cycleSet == "3") {
                            // 第二队列
                            let dsmin = 0;
                            let dshour;
                            let dsweek;
                            if (
                                this.endForm.dsmin === "" ||
                                this.endForm.dshour === "" ||
                                this.endForm.dsweek == "" ||
                                this.endForm.dsweek == undefined
                            ) {
                                this.$message.warning("请将定时执行时间填写完整");
                                return false;
                            }
                            if (this.endForm.dsmin || this.endForm.dsmin == 0) {
                                dsmin = this.endForm.dsmin;
                            }
                            if (this.endForm.dshour || this.endForm.dshour == 0) {
                                dshour = this.endForm.dshour;
                            }
                            if (this.endForm.dsweek) {
                                dsweek = this.weekTrans(this.endForm.dsweek);
                            }
                            pollIntervalMs = `0 ${dsmin} ${dshour} ? * ${dsweek}`;
                        }
                        if (this.endForm.cycleSet == "4") {
                            // 第三队列
                            let dtmin = 0;
                            let dthour;
                            if (this.endForm.dtmin === "" || this.endForm.dthour === "") {
                                this.$message.warning("请将定时执行时间填写完整");
                                return false;
                            }
                            if (this.endForm.dtmin || this.endForm.dtmin == 0) {
                                dtmin = this.endForm.dtmin;
                            }
                            if (this.endForm.dthour || this.endForm.dfhour == 0) {
                                dthour = this.endForm.dthour;
                            }

                            pollIntervalMs = `0 ${dtmin} ${dthour} * * ? *`;
                        }
                    }
                }
                this.endForm.intervalMs = pollIntervalMs;
                this.endForm.timeType =
                    this.endForm.accessWay == "3" ? "" : this.endForm.cycleSet;
                return true;
            },
            formateCron() {
                let strCorn = "* * * * * * *"; // 秒 分 小时 日期 月份 星期 年
                const t = this.endForm.timeValue;
                const date = new Date();
                const curSeconds = date.getSeconds(); // 获取秒
                const curMinute = date.getMinutes(); // 获取分钟
                const curHour = date.getHours(); // 获取小时
                const curDate = date.getDate(); // 当月日期
                const curMonth = date.getMonth(); // 当前月份
                const curYear = date.getFullYear(); // 当前年
                switch (this.endForm.timeType) {
                    case "分": {
                        strCorn = `${curSeconds} */${t} * * * ? *`;
                        break;
                    }
                    case "时": {
                        strCorn = `${curSeconds} ${curMinute} */${t} * * ? *`;
                        break;
                    }
                    case "日期": {
                        strCorn = `${curSeconds} ${curMinute} ${curHour} */${t} * ? *`;
                        break;
                    }
                    case "月份": {
                        strCorn = `${curSeconds} ${curMinute} ${curHour} ${curDate} */${t} ? *`;
                        break;
                    }
                    default:
                        break;
                }
                return strCorn;
            },
            translateCron() {
                let intervalMs = this.endForm.intervalMs;
                //默认选中间隔执行
                if (this.endForm.timeType == "1") {
                    this.endForm.cycleSet = "1";
                    const periodTime = translateTimeFromCRON(
                        this.endForm.intervalMs,
                        this.endForm.timeType
                    ); //转换为正常时间字符串
                    this.endForm.timeType = periodTime.type; //分时日期月份下拉字段
                    this.endForm.timeValue = periodTime.value; //选择的时间
                }
                if (this.endForm.timeType == "2") {
                    this.endForm.cycleSet = "2";
                    let pollMs = intervalMs.split(" ");
                    this.endForm.dfmin = pollMs[1];
                    this.endForm.dfhour = pollMs[2];
                    this.endForm.dfmon = pollMs[3];
                    this.cleanData("2");
                }
                if (this.endForm.timeType == "3") {
                    this.endForm.cycleSet = "3";
                    let pollMs = intervalMs.split(" ");
                    this.endForm.dsmin = pollMs[1];
                    this.endForm.dshour = pollMs[2];
                    this.endForm.dsweek = this.Unweek(pollMs[5]);
                    this.cleanData("3");
                }
                if (this.endForm.timeType == "4") {
                    this.endForm.cycleSet = "4";
                    let pollMs = intervalMs.split(" ");
                    this.endForm.dtmin = pollMs[1];
                    this.endForm.dthour = pollMs[2];
                    this.cleanData("4");
                }
            },
            //清空非选中项
            cleanData(val) {
                if (val == "1") {
                    this.endForm.cycleSet = "";
                    this.endForm.dfmon = "";
                    this.endForm.dfhour = "";
                    this.endForm.dfmin = "";
                    this.endForm.dsweek = "";
                    this.endForm.dshour = "";
                    this.endForm.dsmin = "";
                    this.endForm.dthour = "";
                    this.endForm.dtmin = "";
                }
                if (val == "2") {
                    this.endForm.dsweek = "";
                    this.endForm.dshour = "";
                    this.endForm.dsmin = "";
                    this.endForm.dthour = "";
                    this.endForm.dtmin = "";
                }
                if (val == "3") {
                    this.endForm.dfmon = "";
                    this.endForm.dfhour = "";
                    this.endForm.dfmin = "";
                    this.endForm.dthour = "";
                    this.endForm.dtmin = "";
                }
                if (val == "4") {
                    this.endForm.dfmon = "";
                    this.endForm.dfhour = "";
                    this.endForm.dfmin = "";
                    this.endForm.dsweek = "";
                    this.endForm.dshour = "";
                    this.endForm.dsmin = "";
                }
            },
            // 月数
            _monthData() {
                for (let i = 1; i < 32; i++) {
                    this.$set(this.monthData, i - 1, i);
                }
            },
            _minData() {
                for (let i = 0; i < 60; i++) {
                    this.$set(this.minData, i, i);
                }
            },
            _hourData() {
                for (let i = 0; i < 24; i++) {
                    this.$set(this.hourData, i, i);
                }
            },
            weekTrans(val) {
                if (val == "1") {
                    return "MON";
                }
                if (val == "2") {
                    return "TUE";
                }
                if (val == "3") {
                    return "WED";
                }
                if (val == "4") {
                    return "THU";
                }
                if (val == "5") {
                    return "FRI";
                }
                if (val == "6") {
                    return "SAT";
                }
                if (val == "7") {
                    return "SUN";
                }
            },
            Unweek(val) {
                if (val == "MON") {
                    return 1;
                }
                if (val == "TUE") {
                    return 2;
                }
                if (val == "WED") {
                    return 3;
                }
                if (val == "THU") {
                    return 4;
                }
                if (val == "FRI") {
                    return 5;
                }
                if (val == "SAT") {
                    return 6;
                }
                if (val == "SUN") {
                    return 7;
                }
            },
            _weekData() {
                for (let i = 1; i < 8; i++) {
                    let weekday = "";
                    if (i == 1) {
                        weekday = "一";
                    }
                    if (i == 2) {
                        weekday = "二";
                    }
                    if (i == 3) {
                        weekday = "三";
                    }
                    if (i == 4) {
                        weekday = "四";
                    }
                    if (i == 5) {
                        weekday = "五";
                    }
                    if (i == 6) {
                        weekday = "六";
                    }
                    if (i == 7) {
                        weekday = "日";
                    }
                    this.weekData.push({
                        name: weekday,
                        val: i
                    });
                }
            }
        }
    };
</script>

<style lang='scss' scoped>
    .expand-bar {
        font-size: 14px;
        padding: 10px 0;
        color: #0090ff;
        user-select: none;
        cursor: pointer;
    }

    .out-form {
        padding-top: 10px;
    }

    .ml20 {
        margin-left: 20px;
    }

    .new-title {
        color: #0090ff;
        margin-bottom: 10px;
    }

    .my-flex {
        display: flex;
        flex-direction: row;
    }

    .btn-bt {
        padding: 10px 0;
        text-align: right;
    }

    /deep/ {
        .el-tabs__nav-wrap::after {
            background-color: transparent;
        }

        .el-tabs__active-bar {
            background-color: transparent;
        }

        .el-tabs__item {
            padding: 0 0.2rem 0 0;
        }

        .el-tabs__content {
            padding: 30px;
            background: rgba(247, 250, 252, 0.72);
        }

        .el-tabs--left .el-tabs__item.is-left {
            text-align: left;
        }
    }
</style>
